<%@ page import="edu.uow.devdocs.Project" %>
<%@ page import="edu.uow.devdocs.TimeTracker" %>

<!doctype html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'project.label', default: 'Project')}" />
		<title><g:message code="default.list.label" args="[entityName]" /></title>
		<r:require modules="chosen"/>
	</head>
	<body>
		<div id="list-project" class="content scaffold-list" role="main">
		<p class="action_menu"><g:link class="project_create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></p>
			<h1><g:message code="default.list.label" args="[entityName]" /></h1>
			<g:flashMessage/>
			<table class="sortable tableForm projectList">
				<thead>
					<tr>
						<g:sortableColumn property="id" title="${message(code: 'project.id.label', default: 'Id')}" class="w65" />
						<th><g:message code="project.system.label" default="System" /></th>
						<g:sortableColumn property="name" title="${message(code: 'project.name.label', default: 'Name')}" />
						<th><g:message code="project.status.label" default="Status" /></th>
						<g:sortableColumn property="estimatedHours" title="${message(code: 'project.estimatedHours.label', default: 'Estimated Hours')}" class="w65" />
						<th><g:message code="project.projectType.label" default="Project Type" /></th>
						<g:sortableColumn property="costCentre" title="${message(code: 'project.costCentre.label', default: 'Cost Centre')}" class="w65" />
						<th><g:message code="project.businessOwner.label" default="Business Owner" /></th>
						<th><g:message code="project.developmentManager.label" default="Development Manager" /></th>
						<th><g:message code="project.estimatedHours.label" default="Estimated Hours" /></th>
						<th><g:message code="project.totalHours.label" default="Total Hours" /></th>
						<th></th>
					</tr>
					<tr>
					<form action = "search">
					

	<th> 
	<g:textField name="id" value="${params?.id}" class="w65" />
	</th>



	<th> 
	<g:select id="system" name="system.id" from="${edu.uow.devdocs.System.list()}" optionKey="id" value="${params?.system?.id}" class="many-to-one" noSelection="['null': '']"/>
	</th>



	<th> 
	<g:textField name="name" value="${params?.name}" />
	</th>



	<th> 
	<g:select id="status" name="status.id" from="${edu.uow.devdocs.ProjectStatus.list()}" optionKey="id" value="${params?.status?.id}" class="many-to-one" noSelection="['null': '']"/>
	</th>



	<th> 
	<g:textField name="estimatedHours" value="${params?.estimatedHours}" class="w65" />
	</th>



	<th> 
	<g:select id="projectType" name="projectType.id" from="${edu.uow.devdocs.ProjectType.list()}" optionKey="id" value="${params?.projectType?.id}" class="many-to-one" noSelection="['null': '']"/>
	</th>



	<th> 
	<g:textField name="costCentre" value="${params?.costCentre}" class="w65" />
	</th>



	<th> 
	<g:select id="businessOwner" name="businessOwner.id" from="${edu.uow.devdocs.Person.list()}" optionKey="id" value="${params?.businessOwner?.id}" class="many-to-one" noSelection="['null': '']"/>
	</th>



	<th> 
	<g:select id="developmentManager" name="developmentManager.id" from="${edu.uow.devdocs.Person.list()}" optionKey="id" value="${params?.developmentManager?.id}" class="many-to-one" noSelection="['null': '']"/>
	</th>
	
	<th></th>
	
	<th></th>
					<th><button type="submit">Go</button></th></form></tr>
				</thead>
				<tbody>
				<g:each in="${projectInstanceList}" status="i" var="projectInstance">
					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
						<td><g:link action="edit" id="${projectInstance.id}">${fieldValue(bean: projectInstance, field: "id")}</g:link></td>
						<td>${fieldValue(bean: projectInstance, field: "system")}</td>
						<td>${fieldValue(bean: projectInstance, field: "name")}</td>
						<td>${fieldValue(bean: projectInstance, field: "status")}</td>
						<td>${fieldValue(bean: projectInstance, field: "estimatedHours")}</td>
						<td>${fieldValue(bean: projectInstance, field: "projectType")}</td>
						<td>${fieldValue(bean: projectInstance, field: "costCentre")}</td>
						<td>${fieldValue(bean: projectInstance, field: "businessOwner")}</td>
						<td>${fieldValue(bean: projectInstance, field: "developmentManager")}</td>
						<td>${fieldValue(bean: projectInstance, field: "estimatedHours")}</td>
						<td>${TimeTracker.totalHoursForProject(projectInstance).get()}</td>
						<td></td>
					</tr>
				</g:each>
				</tbody>
			</table>
			<div class="pagination">
				<g:paginate total="${projectInstanceTotal}" />
			</div>
		</div>
	</body>
</html>


